package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.upload.AliOSSUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @BelongsProject: sky-take-out
 * @BelongsPackage: com.sky.controller.admin
 * @Author: XieMingHui
 * @CreateTime: 2023-11-17  21:47
 * @Description: 上传
 * @Version: 1.0
 */
@RestController
@RequestMapping("/admin")
public class CommonController {
    @Resource
   private AliOSSUtils aliOSSUtils;
    @PostMapping("/common/upload")
    public Result<String> ImageUpload(MultipartFile file){
        String url;
        try {
            url = aliOSSUtils.upload(file);
        } catch (IOException e) {
            throw new RuntimeException("上传失败");
        }
        return Result.success(url);

    }



}
